from autoTest_ecshop.utils.log_util import logger

def assert_Utils(expect,compare,actual):
    logger.info(f"断言数据为--{expect},{compare},{actual}")
    try:
        if type(compare)!=type(actual):
            logger.error(f"断言失败，期望数据类型为{type(compare)},实际数据类型为{type(actual)}")
            raise AssertionError
        elif compare == "==":
            assert expect == actual
        elif    compare == "!=":
            assert expect != actual
        elif compare == ">":
            assert expect > actual
        elif compare == ">=":
            assert expect >= actual
        elif compare == "<":
            assert expect < actual
        elif compare == "<=":
            assert expect <= actual
        elif compare == "in":
            assert expect in actual
        elif compare == "not in":
            assert expect not in actual
        else:
            logger.error(f"断言操作符{compare}不被识别")
    except:
        logger.error(f"断言失败，期望数据为{expect},实际数据为{actual}")
        raise AssertionError